﻿<!-- Copyright (c) Microsoft Corporation
 * 
 * All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.  You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 * 
 * THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
 * 
 * See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
-->
<Window x:Class="ProximityTapper.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Proximity Tapper" Height="600" Width="900">
    <Grid>
        <Grid.Resources>
            <Style x:Key="DataGridRowIsOnlineStyle" TargetType="{x:Type DataGridRow}">
                <Setter Property="Background" Value="Green"/>
                <Setter Property="Foreground" Value="White" />
                <Setter Property="FontWeight" Value="Bold" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsOnline}" Value="False">
                        <Setter Property="Background" Value="Red"/>
                        <Setter Property="FontWeight" Value="Normal" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="400" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <StackPanel>
            <GroupBox Header="Devices">
                <StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="IP, hostname or MAC: " />
                        <TextBox x:Name="txtDeviceIP" Width="200" ToolTip="Append a tilde &quot;~&quot; then a device name to specify the name" />
                        <Button x:Name="btnAddDevice" Content="Add Device" Click="btnAddDevice_Click" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                <CheckBox Name="chkShowDiscoveredDevices" IsChecked="true" Content="Auto add discovered devices" />
            </StackPanel>
                    
                    <DataGrid x:Name="dgDevices" Height="200" AutoGenerateColumns="False" IsReadOnly="True" RowStyle="{StaticResource DataGridRowIsOnlineStyle}">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Name}" MinWidth="100" Header="Name" />
                    <DataGridTextColumn Binding="{Binding FriendlyName}" Header="Device Name" />
                    <DataGridTextColumn Binding="{Binding BuildString}" Header="Build" />
                    <DataGridTextColumn Binding="{Binding IpAddress}" Header="IP" />
                    <DataGridTextColumn Binding="{Binding MacAddress}" Header="MAC" />
                    <DataGridTextColumn Binding="{Binding Path=LastPing, StringFormat={}{0:hh:mm:ss.fff tt}}" Header="Last Ping" SortDirection="Descending" />
                </DataGrid.Columns>
                <DataGrid.ContextMenu>
                    <ContextMenu >
                        <MenuItem Header="Remove Device" x:Name="mnuRemoveDevice" Click="mnuRemoveDevice_Click" />
                                <MenuItem Header="Rename Device" x:Name="mnuRenameDevice" Click="mnuRenameDevice_Click" />
                            </ContextMenu>
                </DataGrid.ContextMenu>
            </DataGrid>
                    <Button x:Name="btnRemoveDevice" Content="Remove Selected Device(s)" Click="btnRemoveDevice_Click" />
                    <Button x:Name="btnTapUntapDevices" Content="Tap+Wait 1s+Untap Selected Devices" Click="btnTapUntapDevices_Click" />
                    <Button x:Name="btnTapDevices" Content="Tap Selected Devices and Remain Connected" Click="btnTapDevices_Click" />
                </StackPanel>
            </GroupBox>
            <GroupBox Header="Connections">
                <StackPanel>
                    <ListBox x:Name="lstConnections" SelectionChanged="lstConnections_SelectionChanged" DisplayMemberPath="Caption" Height="100" SelectionMode="Extended" />
                    <Button x:Name="btnUntap" Content="Untap Selected Connection(s)" Click="btnUntap_Click" />
                    <Button x:Name="btnSendURL" Content="Send URL" Click="btnSendURL_Click" />
                    <Button x:Name="btnSendString" Content="Send Unicode String Message" Click="btnSendString_Click" />
                    <Button x:Name="btnSendFile" Content="Send File" Click="btnSendFile_Click" />
                </StackPanel>
            </GroupBox>
        </StackPanel>
        <DataGrid x:Name="dgMessages" Grid.Column="1" AutoGenerateColumns="False" IsReadOnly="True">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding SourceDevice.Caption}" Width="100" Header="SourceDevice" />
                <DataGridTextColumn Binding="{Binding MessageType}" Header="MessageType" />
                <DataGridTextColumn Binding="{Binding DataAsAutoString}" Width="200" Header="Data" />
                <DataGridTextColumn Binding="{Binding Path=ReceivedDate, StringFormat={}{0:hh:mm:ss.fff tt}}" Header="ReceivedDate" />
                <DataGridTextColumn Binding="{Binding TargetDevicesCaption}" Header="TargetDevices" />
            </DataGrid.Columns>
            <DataGrid.ContextMenu>
                <ContextMenu >
                    <MenuItem Header="Resend to All Targets" x:Name="mnuResendMessageToAllTargets" Click="mnuResendMessageToAllTargets_Click"  />
                    <MenuItem Header="Copy payload data as hex to clipboard" x:Name="mnuCopyPayloadAsHex" Click="mnuCopyPayloadAsHex_Click"  />
                </ContextMenu>
            </DataGrid.ContextMenu>
        </DataGrid>
    </Grid>
</Window>
